package com.yazi.mxz.common.service.impl;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.myframework.smhj.hibernate.dao.BasicService;
import com.myframework.smhj.hibernate.dao.Dao;
import com.yazi.mxz.common.db.dao.StoreRegionDao;
import com.yazi.mxz.common.entity.ValueFactory;
import com.yazi.mxz.common.entity.beans.StoreRegion;
import com.yazi.mxz.common.service.StoreRegionService;

@Service("storeRegionService")
public class StoreRegionServiceImpl extends BasicService<StoreRegion> implements StoreRegionService {
	private static Logger log = LoggerFactory.getLogger(StoreRegionServiceImpl.class);
	
	@Resource
	StoreRegionDao storeRegionDao;
	
	@Override
	protected Dao<StoreRegion> getDao() {
		return storeRegionDao;
	}
	
	@Override
	public StoreRegion add(StoreRegion storeRegion) {
		log.debug("add：storeId={},regionId={}", 
				storeRegion.getId().getStoreId(), storeRegion.getId().getRegionId());
		
		ValueFactory.validate(storeRegion);
		return storeRegionDao.persist(storeRegion);
	}

}
